package test1;

import java.util.HashMap;
import java.util.Map;

public class Test2 {
    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        System.out.println(map.size());
        System.out.println(map.isEmpty());
        System.out.println(map.get("罗贯中"));
        System.out.println(map.getOrDefault("罗贯中", "空"));
        System.out.println(map.containsKey("罗贯中"));
        System.out.println(map.containsKey("曹雪芹"));
        map.put("罗贯中", "三国演义");
        map.put("曹雪芹", "红楼梦");
        System.out.println(map.size());
        System.out.println(map.isEmpty());
        System.out.println(map.get("罗贯中"));
        System.out.println(map.get("曹雪芹"));
        System.out.println(map.containsValue("红楼梦"));

        for (Map.Entry<String, String> entry : map.entrySet()) {
            System.out.print(entry.getKey() + " ");
            System.out.print(entry.getValue());
            System.out.println();
        }
    }
}
